package poidemo.docx4j;

import java.io.File;
import org.docx4j.Docx4J;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;

public class DocxToDoc {

	public static void main(String[] args) throws Exception {
		convertDocx2Doc();
	}
	
	private static void convertDocx2Doc() throws Exception {

		//将docx转换为符合doc格式规范的xml文档，再由xml更改后缀名为doc的方式达到docx转换doc格式的目的

		File templateFile = new File("D:\\tmp\\docx\\zgs.docx");

		WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(templateFile);

		File outFile = new File(templateFile.getParent() + "/out/" , "zgs.xml");

		Docx4J.save(wordMLPackage, outFile, Docx4J.FLAG_SAVE_FLAT_XML);//FLAG_SAVE_ZIP_FILE

		outFile.renameTo(new File(outFile.getParentFile() , "我的增量补丁整理软件.doc"));

	}

}
